From 825374c67c695f6d719773f2fd2752ca604dc08a Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 29 Aug 2015 13:14:37 -0400 Subject: [PATCH] Add tests for different arguments given to verify-project Right now, only passing --manifest-path a path to a Cargo.toml file works, but I think not specifying a path and verifying the current working directory, if it has a Cargo.toml, should work as well for consistency with all the other commands that optionally take --manifest-path. --- tests/test_cargo_verify_project.rs | 43 ++++++++++++++++++++++++++++++ tests/tests.rs | 1 + 2 files changed, 44 insertions(+) create mode 100644 tests/test_cargo_verify_project.rs diff --git a/tests/test_cargo_verify_project.rs b/tests/test_cargo_verify_project.rs new file mode 100644 index 000000000..ca7595227 --- /dev/null +++ b/tests/test_cargo_verify_project.rs @@ -0,0 +1,43 @@ +use support::{project, execs, main_file, basic_bin_manifest}; +use hamcrest::{assert_that}; + +fn setup() {} + +fn verify_project_success_output() -> String { + r#"{"success":"true"}"#.into() +} + +test!(cargo_verify_project_path_to_cargo_toml_relative { + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])); + + assert_that(p.cargo_process("verify-project") + .arg("--manifest-path").arg("foo/Cargo.toml") + .cwd(p.root().parent().unwrap()), + execs().with_status(0) + .with_stdout(verify_project_success_output())); +}); + +test!(cargo_verify_project_path_to_cargo_toml_absolute { + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])); + + assert_that(p.cargo_process("verify-project") + .arg("--manifest-path").arg(p.root().join("Cargo.toml")) + .cwd(p.root().parent().unwrap()), + execs().with_status(0) + .with_stdout(verify_project_success_output())); +}); + +test!(cargo_verify_project_cwd { + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])); + + assert_that(p.cargo_process("verify-project") + .cwd(p.root()), + execs().with_status(0) + .with_stdout(verify_project_success_output())); +}); diff --git a/tests/tests.rs b/tests/tests.rs index e9c34dfb0..2fa3ebdb4 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -58,6 +58,7 @@ mod test_cargo_rustc; mod test_cargo_search; mod test_cargo_test; mod test_cargo_tool_paths; +mod test_cargo_verify_project; mod test_cargo_version; mod test_shell; -- 2.30.2